<template>
  <div class="content">
    <el-row :gutter="20">
      <el-col :md="12" :xs="24" class="bg-content">
        <div class="list-top">
          <!-- 按钮列 -->
          <div>
            <el-button size="medium" type="primary" @click="open(1)"
              >添加部门</el-button
            >
            <el-button size="medium" type="primary" @click="open(2)"
              >添加下级</el-button
            >
            <el-button
              size="medium"
              type="primary"
              icon="el-icon-download"
              @click="handleExportXls('部门信息')"
              >导出</el-button
            >
            <el-button size="medium" type="primary" icon="el-icon-upload2"
              >导入</el-button
            >
            <el-button size="medium" plain @click="deletePop(2)"
              >批量删除</el-button
            >
          </div>
          <!-- 菜单 -->
          <div>
            <el-tag class="el-icon-info" style="width: 100%">
              当前选择：{{ treeDataSelected }}
              <el-button
                type="text"
                v-if="treeDataSelected"
                @click="treeDataCancel()"
                >取消选择</el-button
              >
            </el-tag>
            <el-input placeholder="请输入部门名称进行搜索" v-model="filterText">
            </el-input>
            <!-- 树形控件 -->
            <el-tree
            class="filter-tree"
            :data="treeData"
            :props="defaultProps"
            :default-expand-all="isExpand"
            :default-expanded-keys="defaultExpandAll"
            highlight-current
            :filter-node-method="filterNode"
            :expand-on-click-node="false"
            :check-on-click-node="false"
            :show-checkbox="true"
            :check-strictly="checkstrictly"
            ref="treeData"
            node-key="id"
            :current-node-key="treeDataSelected"
            @node-click="treeDataClick"
            @node-contextmenu="rightClick"
            @check="checkboxCheck"
            :default-checked-keys="selectedtreecheckbox"
            >
            </el-tree>
            <!-- 右键点击事件 -->
            <div id="contextmenu" v-show="menuVisible" class="menu">
              <div class="contextmenu__item" @click="addtreedataNode()">
                添加
              </div>
              <div class="contextmenu__item" @click="deletePop(1)">删除</div>
              <div class="contextmenu__item" @click="closemenu()">取消</div>
            </div>
          </div>
        </div>
        <!-- 底部 -->
        <div class="list-footer">
          <el-dropdown @command="treeStatus">
            <el-button>树操作 <i class="el-icon-arrow-up"></i></el-button>
            <el-dropdown-menu slot="dropdown" style="width=100px">
              <el-dropdown-item command="1">父子关联</el-dropdown-item>
              <el-dropdown-item command="2">取消关联</el-dropdown-item>
              <el-dropdown-item command="3">全部勾选</el-dropdown-item>
              <el-dropdown-item command="4">取消全选</el-dropdown-item>
              <el-dropdown-item command="5">展开所有</el-dropdown-item>
              <el-dropdown-item command="6">合并所有</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-col>
      <el-col :md="12" :xs="24" class="bg-content1">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="基本信息" name="first">
            <div class="bg-content">
              <template v-if="!isCheck">
                <el-empty description="请先选择一个部门!1"></el-empty>
              </template>
              <!-- 基本信息 -->
              <template v-if="isCheck">
                <div class="departlist_box">
                  <el-form
                    :model="organRuleForm"
                    :rules="organRules"
                    ref="organRuleForm"
                    label-width="100px"
                    class="demo-ruleForm"
                  >
                    <el-form-item label="机构名称：" prop="departName">
                      <el-input
                        v-model="organRuleForm.departName"
                        placeholder="请输入机构/部门名称"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="上级部门：">
                      <el-input v-model="parentTitle" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="机构编码：">
                      <el-input
                        v-model="organRuleForm.orgCode"
                        placeholder="请输入机构编码"
                        disabled
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="机构类型：" prop="orgCategory">
                      <el-radio-group v-model="organRuleForm.orgCategory">
                        <el-radio
                          label="1"
                          v-show="organRuleForm.orgCategory != 3 ? true : false"
                          >公司</el-radio
                        >
                        <el-radio
                          label="2"
                          v-show="organRuleForm.orgCategory == 3 ? true : false"
                          >部门</el-radio
                        >
                        <el-radio
                          label="3"
                          v-show="organRuleForm.orgCategory == 3 ? true : false"
                          >岗位</el-radio
                        >
                      </el-radio-group>
                    </el-form-item>
                    <el-form-item label="排序：">
                      <el-input-number
                        v-model="organRuleForm.departOrder"
                        controls-position="right"
                        @change="organSort"
                        :min="0"
                        :max="10"
                      ></el-input-number>
                    </el-form-item>
                    <el-form-item label="手机号：">
                      <el-input
                        v-model="organRuleForm.mobile"
                        placeholder="请输入手机号"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="地址：">
                      <el-input
                        v-model="organRuleForm.address"
                        placeholder="请输入地址"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="备注：">
                      <el-input
                        type="textarea"
                        v-model="organRuleForm.memo"
                        placeholder="请输入备注"
                      ></el-input>
                    </el-form-item>
                    <el-form-item class="departlist_lastitem">
                      <el-button
                        @click="resetForm('organRuleForm')"
                        class="el-icon-refresh"
                        >重置</el-button
                      >
                      <el-button
                        type="primary"
                        @click="submitForm('organRuleForm')"
                        class="el-icon-edit"
                        >保存</el-button
                      >
                    </el-form-item>
                  </el-form>
                </div>
              </template>
            </div>
          </el-tab-pane>
          <el-tab-pane label="部门权限" name="second">
            <div class="bg-content">
              <div v-if="!isCheck">
                <el-empty description="请先选择一个部门!2"></el-empty>
              </div>
              <!-- 部门权限 -->
              <div v-if="isCheck">
                <departlistauthority
                  ref="departlistauthority"
                  :authoritytreeData="roleAuthorityList"
                  :authoritySelectedover="roleAuthoritySelectedover"
                  :treeStatus="treeStatus"
                  :isExpand1="isExpand1"
                  @authoritySbumit="authoritySbumit"
                  :parentId="treeDataSelectedid"
                  @openDrawer="openDrawer"
                ></departlistauthority>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    <!-- 添加部门弹窗 -->
    <departlist ref="openClick" @departSubmit="departSubmit"></departlist>
    <!-- 抽屉 -->
    <div class="drawer">
      <el-drawer
        title="数据规则/按钮权限配置"
        :visible.sync="drawer"
        :with-header="true"
        :show-close="false"
        class="Drawerfontsize"
      >
        <el-tabs
          v-model="activeName1"
          @tab-click="handleClick"
          class="drawer_innerBox"
        >
          <el-tab-pane label="用户管理" name="first">
            <div v-if="!isshow">无配置信息！</div>
            <div v-if="isshow">
              <div>
                <el-checkbox v-model="checked">{{ configContent }}</el-checkbox>
              </div>
              <div>
                <el-button
                  size="mini"
                  class="el-icon-s-claim"
                  @click="saveDepartPermissiondatarule"
                  >点击保存</el-button
                >
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-drawer>
    </div>
  </div>
</template>
<script>
import departlist from "../../components/liangliang/departlist";
import departlistauthority from "../../components/liangliang/departlistauthority";
import {
  queryTreeList,
  queryTreeListedit,
  queryTreeListRole,
  queryDepartPermission,
  queryDepartDelete,
  queryDepartQueryDelete,
  querysaveDepartPermission,
  querysysDepartPermission,
  querysaveDepartPermissiondatarule,
  exportXls,
} from "@/api/depart";
export default {
  name: "depart",
  watch: {
    // 监视树形控件
    filterText(val) {
      this.$refs.treeData.filter(val.trim());
    },
    // 监视当前选中节点
    treeDataSelected(id) {
      if (id.toString()) {
        this.$refs["treeData"].setCurrentKey(id);
      } else {
        this.$refs["treeData"].setCurrentKey(null);
      }
    },
  },
  data() {
    return {
      configContent: "",
      checked: false,
      isshow: false,
      activeName1: "first",
      drawer: false,
      isExpand1: true,
      isExpand: true, // 展开与折叠
      defaultExpandAll: [], // 默认所有树展开
      selectedtreecheckbox: [], // 复选框被选中的节点数组 不包括半选
      checkstrictly: true, // 默认父子不关联
      rightClickDataid: "", // 左边节点点击获取id
      rightClickDatatitle: "", // 左边节点点击获取title
      menuVisible: false, // 模态框默认关闭
      roleAuthorityList: [], //权限列表全部数据包括id
      roleAuthoritySelected: [], // 选中权限id key列表
      oldroleAuthoritySelected: [],
      roleAuthoritySelectedover: [], // 复选框选完后的
      isCheck: false, // 默认打开是右边盒子
      dialogFormVisible: false, // 弹窗打开状态
      organRules: {
        departName: [
          { required: true, message: "请输入机构名称!", trigger: "blur" },
        ],
        orgCategory: [
          { required: true, message: "请输入机构类型!", trigger: "change" },
        ],
      }, // 校验规则
      organRuleForm: {
        departName: "",
        orgCode: "",
        orgCategory: "",
        departOrder: "",
        mobile: "",
        address: "",
        memo: "",
      }, // 放进右边表单的节点对象
      treeNodeSelected: {}, // 目前被选中的节点全部data
      parentTitle: "", // 上级部门
      treeDataSelected: "", // 目前被选中的节点title
      treeDataSelectedid: "", // 目前被选中的父节点id
      sontreeDataSelectedid: "",
      defaultProps: {
        children: "children",
        label: "title",
      },
      activeName: "first", //初始加载默认基本信息选中
      filterText: "", // 搜索框初始值
      treeData: [], // 树形控件数据
    };
  },
  methods: {
    // 导出
    handleExportXls(fileName) {
      let _self = this;
      exportXls().then((res) => {
        if (typeof window.navigator.msSaveBlob !== "undefined") {
          window.navigator.msSaveBlob(
            new Blob([res], { type: "application/vnd.ms-excel" }),
            "导出文件.xls"
          );
        } else {
          let url = window.URL.createObjectURL(
            new Blob([res], { type: "application/vnd.ms-excel" })
          );
          let link = document.createElement("a");
          link.style.display = "none";
          link.href = url;
          link.setAttribute("download", "导出文件.xls");
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      });
    },
    // 修改配置权限
    saveDepartPermissiondatarule() {
      let a = "";
      if (this.checked) {
        a = "32b62cb04d6c788d9d92e3ff5e66854e";
      } else {
        a = "";
      }
      let data = {
        dataRuleIds: a,
        departId: this.treeDataSelectedid,
        permissionId: this.sontreeDataSelectedid,
      };
      querysaveDepartPermissiondatarule(data).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.message,
            type: "success",
          });
        } else if (res.code == 500) {
          this.$message({
            type: "info",
            message: res.message,
          });
        }
      });
    },
    // 获取抽屉配置
    GetDepartPermission(a) {
      let _self = this;
      let data = {
        key: a,
        parentId: this.treeDataSelectedid,
      };
      querysysDepartPermission(data).then((res) => {
        if (res.code == 500) {
          _self.isshow = false;
        } else if (res.code == 200) {
          _self.isshow = true;
          _self.configContent = res.result.datarule[0].ruleName;
          if (res.result.drChecked) {
            _self.checked = true;
          } else {
            _self.checked = false;
          }
        }
      });
    },
    // 抽屉
    openDrawer(statu, sonKey) {
      let _self = this;
      _self.drawer = statu;
      _self.sontreeDataSelectedid = sonKey;
      _self.GetDepartPermission(sonKey);
    },
    // 保存权限
    authoritySbumit(selectedObj) {
      let _self = this;
      let data = {
        departId: _self.treeDataSelectedid,
        lastpermissionIds: _self.oldroleAuthoritySelected.toString(),
        permissionIds: selectedObj.toString(),
      };
      querysaveDepartPermission(data).then((res) => {
        if (res.code == 200) {
          _self.$message({
            message: res.message,
            type: "success",
          });
          _self.queryTreeListRoleSearch();
          _self.queryDepartPermissionSearch();
        }
      });
    },
    // 批量删除
    selectedDelete() {
      // console.log(this.$refs.treeData.getCheckedNodes());
      let _self = this;
      let deleteArray = [];
      for (let item of _self.selectedtreecheckbox) {
        deleteArray.push(item.id);
      }
      let data = deleteArray.join(",");
      queryDepartQueryDelete(data).then((res) => {
        if (res.code == 200) {
          _self.$message({
            message: res.message,
            type: "success",
          });
          _self.queryTreeListSearch();
        }
      });
    },
    // 左边复选框点击事件 每点击一次复选框 都要将当前checkednode获取刷新
    checkboxCheck(a, b, c, d) {
      // console.log(a);
      // console.log(b);
      // console.log(c);
      // console.log(d);
      // console.log(this.$refs.treeData.store._getAllNodes());
      this.selectedtreecheckbox = this.$refs.treeData.getCheckedNodes();
      // console.log( this.selectedtreecheckbox);
    },
    // 处理treedata数据 递归将所有值放在一起
    treeDataHandle(obj, ObjAll) {
      for (let item of obj) {
        ObjAll.push(item);
        if (item.children != null) {
          this.treeDataHandle(item.children, ObjAll);
        }
      }
      return ObjAll;
      // console.log("1")
    },
    // 处理treedata数据 递归将所有key值放在一起
    treeKeysHandle(obj, ObjAll) {
      for (let item of obj) {
        ObjAll.push(item.id);
      }
      return ObjAll;
    },
    //遍历树的所有子节点，展开的时候给子节点展开状态赋值true，折叠时候赋值false
    buildData() {
      for (
        let i = 0;
        i < this.$refs.treeData.store._getAllNodes().length;
        i++
      ) {
        this.$refs.treeData.store._getAllNodes()[i].expanded = this.isExpand;
      }
    },
    // 左边盒子下面的树操作
    treeStatus(key) {
      let _self = this;
      if (key == 1) {
        _self.checkstrictly = false;
      } else if (key == 2) {
        _self.checkstrictly = true;
      } else if (key == 3) {
        let treeObj = [];
        this.selectedtreecheckbox = _self.treeDataHandle(this.treeData,treeObj);
        // this.selectedtreecheckbox = this.treeData;
        // this.selectedtreecheckbox = this.$refs.treeData.getCheckedNodes();
        // console.log(this.selectedtreecheckbox);
        // console.log(this.$refs.treeData.getCheckedNodes());
      } else if (key == 4) {
        _self.selectedtreecheckbox = [];
      } else if (key == 5) {
        // let treeObj = [];
        // treeObj = _self.treeDataHandle(this.treeData,treeObj);
        // let treeKeysObj = [];
        // treeKeysObj = _self.treeKeysHandle(treeObj,treeKeysObj);
        // // console.log(treeKeysObj);
        // _self.defaultExpandAll = treeKeysObj;
        this.isExpand = true;
        this.buildData();
      } else if (key == 6) {
        this.isExpand = false;
        this.buildData();
        // _self.defaultExpandAll=["1842e12d5b7c4e7691192d39bd60f63d"];
        // console.log(_self.defaultExpandAll)
      } else if (key == 7) {
        let treeObj = [];
        this.roleAuthoritySelectedover = this.treeDataHandle(
          this.roleAuthorityList,
          treeObj
        );
        console.log(this.roleAuthoritySelectedover);
      } else if (key == 8) {
        _self.roleAuthoritySelectedover = [];
      } else if (key == 9) {
        this.isExpand1 = true;
        this.$nextTick(() => {
          this.$refs.departlistauthority.buildData();
        });
      } else if (key == 10) {
        this.isExpand1 = false;
        this.$nextTick(() => {
          this.$refs.departlistauthority.buildData();
        });
      }
      this.$nextTick(() => {
        this.$refs.treeData.setCheckedNodes(this.selectedtreecheckbox);
        this.$refs.departlistauthority.treeStatusSon();
      });
    },
    // 处理接口调回来的右边盒子复选框状态的数据
    treenodeCheckbox(alldata, selectdata) {
      // console.log(selectdata);
      let _self = this;
      if (alldata.length && selectdata) {
        let array = selectdata;
        for (let item of alldata) {
          // console.log(item)
          if (item.children) {
            // 这个for处理完成了当前这一层有children的父节点在selectdata中的删除
            for (let select of array) {
              if (select == item.key) {
                // console.log(array);
                // console.log(select);
                let array1 = array.filter(function (x) {
                  return x != select;
                });
                array = array1;
              }
            }
            _self.roleAuthoritySelected = array;
            _self.treenodeCheckbox(item.children, _self.roleAuthoritySelected);
          }
        }
        _self.roleAuthoritySelectedover = _self.roleAuthoritySelected;
      }
      this.$refs.departlistauthority.treeStatusSon();
    },
    // 添加左边节点
    addtreedataNode() {
      this.$refs.openClick.open(
        this.rightClickDatatitle,
        this.rightClickDataid
      );
    },
    // 删除左边节点
    deletetreedataNode() {
      let _self = this;
      let data = _self.rightClickDataid;
      queryDepartDelete(data).then((res) => {
        if (res.code == 200) {
          _self.$message({
            message: res.message,
            type: "success",
          });
          _self.queryTreeListSearch();
        }
      });
    },
    // 确认删除弹窗
    deletePop(val) {
      if (val == 1) {
        this.$confirm("确定要删除此部门以及子节点数据吗?", "确认删除", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.deletetreedataNode();
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      } else if (val == 2) {
        let _self = this;
        _self.selectedtreecheckbox = this.$refs.treeData.getCheckedNodes();
        if (_self.selectedtreecheckbox.length) {
          this.$confirm(
            "确定要删除所选中的 " +
              _self.selectedtreecheckbox.length +
              " 条数据，以及子节点数据吗?",
            "确认删除",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          )
            .then(() => {
              this.selectedDelete();
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消删除",
              });
            });
        } else {
          this.$message({
            showClose: true,
            message: "请选择至少一条记录！",
            type: "warning",
          });
        }
      }
    },
    // 弹窗关闭
    closemenu() {
      this.foo();
    },
    foo() {
      // 取消鼠标监听事件 菜单栏
      this.menuVisible = false;
      document.removeEventListener("click", this.foo); // 关掉监听，
    },
    // 右键弹窗绝对定位相对于鼠标的位置
    styleMenu(menu) {
      menu.style.left = event.pageX - 220 + "px";
      document.addEventListener("click", this.foo); // 给整个document新增监听鼠标事件，点击任何位置执行foo方法
      menu.style.top = event.pageY - 120 + "px";
    },
    // 右键点击节点触发事件 获取当前节点的数组和父节点parentId
    rightClick(row, column, event) {
      // console.log(row);
      console.log(column);
      // console.log(event);
      this.pid = column.id;
      this.testModeCode = row.testModeCode;
      this.menuVisible = false; // 先把模态框关死，目的是 第二次或者第n次右键鼠标的时候 它默认的是true
      this.menuVisible = true; // 显示模态窗口，跳出自定义菜单栏
      // event.preventDefault() //关闭浏览器右键默认事件
      this.CurrentRow = row;
      var menu = document.querySelector(".menu");
      this.styleMenu(menu);
      this.rightClickDataid = column.id;
      this.rightClickDatatitle = column.title;
      // console.log(this.righttreeDataSelectedid);
    },

    // 获取选中权限状态
    queryDepartPermissionSearch() {
      let _self = this;
      let data = {
        departId: _self.treeDataSelectedid,
      };
      queryDepartPermission(data).then((res) => {
        if (res.code == 0) {
          _self.roleAuthoritySelected = res.result;
          _self.oldroleAuthoritySelected = res.result;
          _self.treenodeCheckbox(
            _self.roleAuthorityList,
            _self.roleAuthoritySelected
          );
          this.$refs.departlistauthority.treeStatusSonKeys();
        }
        // console.log(_self.roleAuthoritySelected);
      });
    },
    // 获取权限列表
    queryTreeListRoleSearch() {
      let _self = this;
      queryTreeListRole().then((res) => {
        if (res.code == 0) {
          _self.roleAuthorityList = res.result.treeList;
        }
      });
      // console.log(_self.roleAuthorityList);
    },
    // 添加部门完成后重新获取树形控件
    async departSubmit(childMessage) {
      let _self = this;
      // console.log(childMessage);
      this.$message({
        showClose: true,
        message: childMessage,
        type: "success",
      });
      _self.queryTreeListSearch();
    },
    // 添加部门 打开子组件弹窗   2的情况下下把当前父节点的id和title传给子组件
    open(num) {
      // console.log(this.$refs)
      if (num == 1) {
        this.$refs.openClick.open();
      } else if (num == 2) {
        if (this.treeDataSelected) {
          this.$refs.openClick.open(
            this.treeDataSelected,
            this.treeDataSelectedid
          );
        } else {
          this.$message({
            showClose: true,
            message: "请先选中上级部门！",
            type: "warning",
          });
        }
      }
    },
    // 排序
    organSort(value) {
      console.log(value);
    },
    // 修改树形控件数据
    TreeListNodeEdit() {
      let _self = this;
      _self.organRuleForm.departName = _self.organRuleForm.departName.trim();
      _self.organRuleForm.mobile = _self.organRuleForm.mobile.trim();
      _self.organRuleForm.address = _self.organRuleForm.address.trim();
      _self.organRuleForm.memo = _self.organRuleForm.memo.trim();
      let data = _self.organRuleForm;
      // console.log(data)
      queryTreeListedit(data).then((res) => {
        if (res.code == 200) {
          _self.$message({
            message: res.message,
            type: "success",
          });
          _self.queryTreeListSearch();
        }
      });
    },
    // 校验
    submitForm(formName) {
      let _self = this;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          _self.TreeListNodeEdit();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 重置
    resetForm(formName) {
      let _self = this;
      this.$refs[formName].resetFields();
      _self.organRuleForm.departOrder = "0";
      _self.organRuleForm.mobile = "";
      _self.organRuleForm.address = "";
      _self.organRuleForm.memo = "";
      _self.organRuleForm.departName = "";
      _self.organRuleForm.orgCategory = 0;
    },

    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 树形控件 对树节点进行筛选时执行的方法，返回 true 表示这个节点可以显示，返回 false 则表示这个节点会被隐藏
    // 取消选择
    treeDataCancel() {
      let _self = this;
      // _self.treeNodeSelected = {};
      _self.treeDataSelected = "";
      _self.treeDataSelectedid = "";
      _self.isCheck = false;
    },
    // 获取当前选中的节点
    async treeDataClick(data, data2, data3) {
      // console.log(data);
      // console.log(data2.parent.data.title)
      let _self = this;
      _self.isCheck = true;
      _self.treeNodeSelected = { data };
      _self.organRuleForm = JSON.parse(
        JSON.stringify(_self.treeNodeSelected.data)
      );
      _self.treeDataSelected = data.title;
      _self.parentTitle = data2.parent.data.title;
      _self.treeDataSelectedid = data.id;
      await _self.queryTreeListRoleSearch();
      await _self.queryDepartPermissionSearch();
      //  this.$refs.departlistauthority.checkboxmethod();
      // console.log(_self.roleAuthorityList.treeList);
      // console.log(_self.roleAuthoritySelected);
      // console.log(_self.treeNodeSelected)
      // console.log(_self.treeDataSelected)
      // console.log(_self.treeDataSelectedid)
      // console.log(JSON.stringify(_self.organRuleForm));
    },
    // 树形控件关键字查找
    filterNode(value, treeData) {
      if (!value) return true;
      return treeData.title.indexOf(value) !== -1;
    },
    // 获取树形控件数据
    async queryTreeListSearch() {
      let _self = this;
      _self.treeData = [];
      await queryTreeList().then((res) => {
        // console.log(res.result);
        if (res.code == 0) {
          _self.treeData = res.result;
        }
      });
      await this.$nextTick(() => {
        this.$refs.treeData.setCheckedNodes(this.selectedtreecheckbox);
      });
    },
  },
  mounted() {
    let _self = this;
    _self.queryTreeListSearch();
  },
  components: {
    departlist,
    departlistauthority,
  },
};
</script>
<style lang="less" scoped>
.content {
  margin-left: 12px;
  background-color: #f0f2f5;
  /deep/ .el-drawer {
    width: 360px !important;
  }
}
.bg-content1 {
  min-width: 555px;
}
.bg-content {
  padding: 0px !important;
  background-color: #fff;
  border-radius: 6px;
  min-width: 555px;
  .el-button {
    margin-right: 4px;
    margin-left: 0px;
  }
  .list-top {
    margin: 20px 20px 0px 40px;
    .el-tag {
      margin: 10px 0;
      height: 40px;
      line-height: 40px;
    }
    .el-input {
      margin-bottom: 10px;
    }
    .el-tree {
      margin-bottom: 10px;
    }
  }
  .list-footer {
    padding: 12px 0px 10px 16px;
    border-top: 1px solid #e8e8e8;
  }
  .rightBox {
    margin: 10px;
  }
}
.rightBox {
  width: 100%;
}
.departlist_box {
  margin-right: 75px;
  margin-left: calc(100%-90px);
  padding-top: 20px;
  .el-input--suffix .el-input__inner {
    padding-left: 20px;
  }
  .departlist_lastitem {
    padding-bottom: 30px;
    text-align: center;
  }
  .el-select {
    width: 100%;
  }
}
// 右键弹窗
.contextmenu__item {
  display: block;
  line-height: 34px;
  text-align: center;
}
.contextmenu__item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.menu {
  position: absolute;
  background-color: #fff;
  width: 100px;
  /*height: 106px;*/
  font-size: 12px;
  color: #444040;
  border-radius: 4px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  white-space: nowrap;
  z-index: 1000;
}
.contextmenu__item:hover {
  cursor: pointer;
  background: #66b1ff;
  border-color: #66b1ff;
  color: #fff;
}
.drawer_innerBox {
  margin: 0px 40px;
}
.Drawerfontsize {
  font-size: 16px;
  color: black;
}
</style>